﻿namespace Home.Repository
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.ModelConfiguration;
    using System.Linq;
    using System.Web;
    using Home.Data;
    using Home.Models;

    public class OptimizationDbContext : EntityFrameworkDbContext
    {
        static OptimizationDbContext()
        {
            Database.SetInitializer<OptimizationDbContext>(null);
        }

        public OptimizationDbContext()
            : base("Name=DefaultConnection", false)
        {
        }

        public DbSet<OptimizationComment> Comments { get; set; }

        public DbSet<OptimizationVisit> Visits { get; set; }

        protected override void OnModelCreating(DbModelBuilder builder)
        {
            {
                var entity = builder.CreateEntity<OptimizationComment>("t_optimization_visitor_comment");

                entity.Property(m => m.VisitorId)
                      .HasColumnName("visitor_id")
                      .IsRequired();

                entity.Property(m => m.RegisteredUserId)
                      .HasColumnName("registered_user_id")
                      .IsOptional();

                entity.Property(m => m.CategoryKey)
                      .HasColumnName("category_key")
                      .IsRequired()
                      .HasMaxLength(2048)
                      .IsUnicode(false)
                      .IsVariableLength();

                entity.Property(m => m.CategoryValue)
                      .HasColumnName("category_value")
                      .IsOptional()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();

                entity.Property(m => m.ParentId)
                      .HasColumnName("parent_id")
                      .IsOptional();

                entity.Property(m => m.Content)
                      .HasColumnName("content")
                      .IsOptional()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();

                entity.Property(m => m.Score)
                      .HasColumnName("score")
                      .IsOptional();
            }

            {
                var entity = builder.CreateEntity<OptimizationVisit>("t_optimization_visitor_visit");

                entity.Property(m => m.VisitorId)
                      .HasColumnName("visitor_id")
                      .IsRequired();

                entity.Property(m => m.RegisteredUserId)
                      .HasColumnName("registered_user_id")
                      .IsOptional();

                entity.Property(m => m.Category)
                      .HasColumnName("category")
                      .IsRequired();

                entity.Property(m => m.CategoryDetail)
                      .HasColumnName("category_detail")
                      .IsOptional()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();

                entity.Property(m => m.Url)
                      .HasColumnName("url")
                      .IsRequired()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();

                entity.Property(m => m.Referer)
                      .HasColumnName("referer")
                      .IsOptional()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();

                entity.Property(m => m.Agent)
                      .HasColumnName("agent")
                      .IsOptional()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();

                entity.Property(m => m.Geolocation)
                      .HasColumnName("geolocation")
                      .IsOptional()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();

                entity.Property(m => m.Language)
                      .HasColumnName("language")
                      .IsOptional()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();

                entity.Property(m => m.Platform)
                      .HasColumnName("platform")
                      .IsOptional()
                      .HasMaxLength(2048)
                      .IsUnicode(true)
                      .IsVariableLength();
            }
        }
    }
}